#set(seoTitle="发布文章")
#@layout()
#define main()
<!-- 内容区域 -->
<div class="aw-container-wrap">
	<div class="container aw-publish aw-publish-article">
		<div class="row">
			<div class="aw-content-wrap clearfix">
				<div class="col-sm-12 col-md-12 aw-main-content">
					<!-- tab 切换 -->
					<ul class="nav nav-tabs aw-nav-tabs active">
						<h2><i class="icon icon-ask"></i>修改文章</h2>
					</ul>
					<!-- end tab 切换 -->
					<form id="myArticleForm" action="/my/article/update" method="post" name="write_post" >
						<input type="hidden" name="article.aid" value="#(article.aid)" />
						<div class="aw-mod aw-mod-publish">
							<div class="mod-body">
								<!-- 文章标题 -->
								<div class="aw-publish-title">
									<div class="input-group" style="margin-top: 10px">
										<span class="input-group-addon" id="basic-addon3">文章标题</span>
										<input type="text" name="article.title" value="#(article.title)" class="form-control">
										<span class="input-group-addon" id="basic-addon4">分类</span>
										<select name="article.type_id" class="form-control" id="article.type_id">
											#for(comments : commentsList)
											#if(comments.tid == article.type_id)
											<option value="#(comments.tid)" selected>#(comments.name)</option>
											#else
											<option value="#(comments.tid)">#(comments.name)</option>
											#end
											#end
										</select>
									</div>
								</div>
								<!-- end 文章标题 -->
								#if(article.is_pay==1)
								<p></p>
								<div class="aw-publish-title">
									<div class="input-group" style="margin-top: 10px">
										<span class="input-group-addon" id="basic-addon5">下载链接</span>
										<input type="text" name="article.download" value="#(article.download)" class="form-control" placeholder="请输入下载链接"><br/>
									</div>
									<div class="input-group" style="margin-top: 10px">
										<span class="input-group-addon" id="basic-addon6">下载密码</span>
										<input type="text" name="article.password" value="#(article.password)" class="form-control" placeholder="请输入下载密码">
										<span class="input-group-addon" id="basic-addon7">使用积分</span>
										<select name="article.points" class="form-control" id="article.points">
											<option value="1">1个积分</option>
											<option value="2">2个积分</option>
											<option value="3">3个积分</option>
											<option value="4">4个积分</option>
											<option value="5">5个积分</option>
											<option value="6">6个积分</option>
											<option value="7">7个积分</option>
											<option value="8">8个积分</option>
											<option value="9">9个积分</option>
											<option value="10">10个积分</option>
										</select>
									</div>
								</div>
								#end
								<h3>文章内容:</h3>
								<div class="content-box"  style="line-height: 20px;border: 1px solid #d1d1d1;" >
									<textarea id="editor1" name="article.content">#escape(article.content ??)</textarea>
								</div>
							</div>
							<div class="mod-footer clearfix">
								<a href="/detail/1" target="_blank">[积分规则]</a>
								<span class="aw-anonymity"></span>
								<input class="btn btn-large btn-success btn-publish-submit" type="submit" value="确认&nbsp;发起" />
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- 内容区域end -->
#end

#define js()
<script type="text/javascript" src="/static/lib/jquery_form/jquery.form.min.js"></script>
<script src="/static/lib/ckeditor/ckeditor.js"></script>
<script>
	$(function() {
		// 初始化 ckeditor
		CKEDITOR.replace('editor1', {height: '350px'});
		// 设置第一个 input 为输入焦点
		$("input:first").focus();
		// 使用 jquery form 插件，接管表单提交事件，并将表单提交自动转化成 ajax 提交
		$("#myArticleForm").ajaxForm({
			dataType: 'json', type: 'POST',
			beforeSerialize: function($form, options) {
				// 将 ckeditor 中的数据同步到 textarea，否则数据无法提交到服务端
				for (instance in CKEDITOR.instances) {
					CKEDITOR.instances[instance].updateElement();
				}
				kit.loading({msg: '正在保存, 请稍候 .....'});
			},
			success: function(ret) {
				kit.closeLoading();
				kit.msg(ret);
				if (ret.state == "ok") {
					kit.go('/my/article/list');
				}
			}
		});

	});
</script>
#end
